﻿#include "QuestionBase.h"

QuestionProvider::QuestionProvider()
{
	m_CurrentIndex = 0;
}

wstring QuestionProvider::GetCurrentQuestionTitle()
{
	Question curQuestion = m_QuestionPool->m_Questions[m_CurrentIndex];

	return curQuestion.m_Title;
}

wstring QuestionProvider::GetCurrentOptionA()
{
	return m_QuestionPool->m_Questions[m_CurrentIndex].m_Options[OptionA];
}

wstring QuestionProvider::GetCurrentOptionB()
{
	return m_QuestionPool->m_Questions[m_CurrentIndex].m_Options[OptionB];
}

wstring QuestionProvider::GetCurrentQuestionAnswer()
{
	Question curQuestion = m_QuestionPool->m_Questions[m_CurrentIndex];

	return curQuestion.m_Answer;
}

wstring QuestionProvider::GetCurrentIndexString()
{
	wchar_t buf[10];
	swprintf(buf,10,L"这是第 %d 题",m_CurrentIndex+1);
	wstring qIndex = buf;

	return qIndex;
	delete[] &buf;
}


bool QuestionProvider::BindQuestionPool(QuestionPool *questionPool)
{
	// Valid questionpool
	if(questionPool->m_Size > 0)
	{
		m_QuestionPool = questionPool;
		return true;
	}
	else
	{
		return false;
	}
}

bool QuestionProvider::IsLastQuestion()
{
	return m_CurrentIndex >= m_QuestionPool->m_Size;
}

// Tell QuestionProvider go to next question
void QuestionProvider::Next()
{
	if(!IsLastQuestion())
	{
		// Increase index 
		m_CurrentIndex ++;
	}
}